<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>短网址生成器</title>
<base target="_blank" />
<style type="text/css">
body{ background:#000;overflow-x:hidden; }
a{ text-decoration:none;font-size:18px; color:#00F;}
.form_contain{ width:680px; margin:0 auto;}
input[type="text"]{ width:500px; height:50px; font-size:30px; vertical-align:middle; }
input[type="button"]{ width:150px; height:50px;  font-size:20px;background:#FE2F67; border:none; padding:5px 10px; color:#FFF; font-weight:bold; font-weight:bold; vertical-align:middle; cursor:pointer; }
input[type="button"]:hover{ background:#FC1F5B;}
h1{ color:#F00;text-align:center;  }
.ajax_info{width:680px; margin:0 auto; color:#FFF; margin-top:10px; line-height:22px; }
.ajax_info a{ color:#00F;}
.ajax_info a:visited{ color:#00F;}
.footer{margin:0 auto;position:absolute; bottom:0; width:99%; }
.footer p{ text-align:center;  color:#FFF;width:99%;  }
@media screen and (max-width:700px) {
	h1{ margin-left:10px;}
	.form_contain{ width:auto;}
	input[type="text"]{ width:90%;}
	input[type="button"]{ width:50%; margin-top:10px;}
	.ajax_info{width:auto;}
	.footer p{ width:auto;}
}
</style>
</head>

<body>
	<!--输入表单 start-->
	<div class="form_contain">
    	<h1>短网址生成器</h1>
        <input type="text" class="oriurl" placeholder="在此输您的入网址" />
        <input type="button" class="oribtn" value="生成短网址" />
    </div>
    <!--输入表单 end-->
    
    <!--提示信息 start-->
    <div class="ajax_info">
        {$nofind}
    </div>
    <!--start end-->
    
    <!--底部 start-->
    <div class="footer">
    <p>Power By <a href="http://blog.clmao.com">Clmao</a></p>
    </div>
    <!--底部 end-->
</body>
</html>
<script type="text/javascript" src="__PUBLIC__/js/jquery.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/layer/layer.min.js"></script>
<script type="text/javascript">
//去掉字符串前后的空格
function trim(str){
	str = str.replace(/^(\s|\u00A0)+/,'');
	for(var i=str.length-1;i>=0;i--){
		if(/\S/.test(str.charAt(i))){
			str = str.substring(0,i+1);
			break;
		}
	}
	return str;	
}
//ajax发送、接收
function senddata(){
    var oriurl = $(".oriurl").val();
    oriurl = trim(oriurl);

    if(oriurl==''||oriurl==null||oriurl==undefined){
            layer.alert('请输入您的网址', 3);
            return false;
    }
    $.post(
            '{:U('Ajax/index')}',
            {'oriurl':oriurl},
            function(url){
                    if(url=='0'){
                        layer.alert('请输入您的网址', 3);
                        return false;
                    }
                    $('.ajax_info').html("生成成功，你的短网址是：<a href='{$root}"+url+"'>{$root}"+url+"</a>");
            }
    );
}


$(function(){
	$(".oribtn").click(function(){
            senddata();
	});
});
$(window).keydown(function(event){
    e = event.keyCode;
    if (e===13) { 
        senddata();
    } 
});
</script>